package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.common.minio.service.FileUploadService;
import com.atguigu.tingshu.common.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "上传管理接口")
@RestController
@RequestMapping("api/album")
public class FileUploadApiController {



    @Autowired
    private FileUploadService fileUploadService;


    //Request URL: http://localhost:8500/api/album/fileUpload


    @Operation(summary = "上传文件")
    @PostMapping("/fileUpload")
    //接受前端发来的文件用@RequestPart注解
    public Result fileUpload(@RequestPart MultipartFile file) throws Exception {
        String picUrl= fileUploadService.fileUpload(file);

        return Result.ok(picUrl);
    }

}
